import { createStore,applyMiddleware,compose } from 'redux';
import thunk from 'redux-thunk';
import {createHashHistory} from 'history'
import { routerMiddleware } from 'connected-react-router'
import mainReducer from './reducers/main.js';
export const history = createHashHistory()
history.replace('menu')
export default function configureStore(preloadedState) {
  const store = createStore(
    mainReducer(history), // root reducer with router state
    preloadedState,
    compose(
      applyMiddleware(
        routerMiddleware(history), // for dispatching history actions
        thunk
      ),
    ),
  )
  return store
}

if (module.hot) {
  module.hot.accept('./reducers/main', ()=>{
    const nextRootReducer = require('./reducers/main.js').default;
    configureStore().replaceReducer(nextRootReducer)
  });
}
